package ch.fhnw.ams.sudoku;


/**
 * Encapsulates the solving algorithm. The solving algorithm is executed by
 * {@link SudokuGame#solve()} in 4 steps.
 * 
 * <ol>
 * <li>commit sudoku data to the solver</li>
 * <li>search a solution</li>
 * <li>inform if a solution is found</li>
 * <li>return solved sudoku</li>
 * </ol>
 * 
 * @author amsler
 * 
 */
public interface ISolver {
	
	/**
	 * Sets the Sudoku data.
	 * 
	 * @param data
	 *            Sudoku data with the format <code>int[row][colum]</code>. Size
	 *            of row and column must be 9.
	 * @throws InvalidSudokuException
	 *             Thrown when data does not match format.
	 */
	void setData(int[][] data) throws InvalidSudokuException;
	
	/**
	 * Search a solution for the Sudoku. This method should be blocking.
	 */
	void generateSolution();
	
	/**
	 * After invoking {@link #generateSolution()}, this method should return
	 * <code>true</code> if the Sudoku has a solution
	 * 
	 * @return <code>true</code> if a solution is found
	 */
	boolean hasSolution();
	
	/**
	 * Gets the solved Sudoku. Invoke only if {@link #generateSolution()}
	 * returns true.
	 * 
	 * @return Sudoku data with the format <code>int[row][colum]</code>. Size of
	 *         row and column must be 9.
	 */
	int[][] getSolution();
	
}
